var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("GameConstant"),
s = t("Util"),
l = t("Global"),
c = t("GatlinHitEffect"),
d = cc._decorator,
h = d.ccclass,
p = d.property,
u = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.collider = null,
        e.pfb_hitEff = null,
        e.par_fire = null,
        e._speed = 0,
        e._gravity = 0,
        e.degree = 0,
        e.curPos = null,
        e.nextPos = null,
        e.isAction = !1,
        e.destroyBullet = function() {
            s.Util.objectPool.putNodeIntoNodePool(l.PoolKey.Grenade, this.node)
        },
        e
    }
    return n(e, t),
    e.prototype.init = function(t, e, o, i, n, a) {
        this.node.position = i,
        this._gravity = 0,
        this._speed = a,
        this.setScale(e == r.Collide_Car_Tag.Right, o),
        this.curPos = this.node.position,
        this.collider.tag = t,
        this.node.scaleX >= 0 ? (this.node.angle = n, this.par_fire.angle = -180) : (this.node.angle = n - 90, this.par_fire.angle = 0),
        this.degree = this.node.angle / 180 * Math.PI,
        this.isAction = !0,
        this.scheduleOnce(this.destroyBullet, 2)
    },
    e.prototype.setScale = function(t, e) {
        var o = 1;
        o = r.Cur_Game_Type == r.Game_Type.PK ? r.Game_Type_Scale.PK: 1,
        o = e < 0 ? -o: o,
        this.node.scale = t ? -o: o
    },
    e.prototype.lookAtDirection = function() {
        this.nextPos = this.node.position;
        var t = (this.node.scaleX >= 0 ? this.nextPos.sub(this.curPos).normalize() : this.curPos.sub(this.nextPos).normalize()).signAngle(cc.v2(1, 0)) / Math.PI * 180;
        this.node.rotation = cc.misc.lerp(this.node.rotation, t, .2),
        this.curPos = this.nextPos
    },
    e.prototype.update = function() {
        if (this.isAction) {
            this._gravity += 1.5;
            var t = cc.Vec2.ZERO,
            e = cc.v2(this.node.x, this.node.y);
            this.node.scaleX >= 0 ? (e.x += this._speed * Math.cos(this.degree), e.y += this._speed * Math.sin(this.degree)) : (e.x -= this._speed * Math.cos(this.degree), e.y -= this._speed * Math.sin(this.degree)),
            e.y -= this._gravity,
            cc.Vec2.lerp(t, this.node.getPosition(), e, .2),
            this.node.setPosition(t),
            this.lookAtDirection()
        }
    },
    e.prototype.removeItem = function(t) {
        if (this.node && this.node.parent) {
            var e = this.node.parent.convertToNodeSpaceAR(t),
            o = s.Util.objectPool.getNodeFromNodePool(l.PoolKey.GrenadeHitEff, this.pfb_hitEff);
            this.node.parent.addChild(o),
            o.setPosition(e),
            o.getComponent(c.default).init(l.PoolKey.GrenadeHitEff)
        }
        this.unschedule(this.destroyBullet),
        this.destroyBullet()
    },
    a([p(cc.Collider)], e.prototype, "collider", void 0),
    a([p(cc.Prefab)], e.prototype, "pfb_hitEff", void 0),
    a([p(cc.ParticleSystem)], e.prototype, "par_fire", void 0),
    a([h], e)
} (cc.Component);
o.default = u